<?php
	session_start();
include_once '../pushing.php';

if ($pushTime == true) {
	if ($_SESSION['UserId'] != 3)
		header('Location: push.php');
}
	
	if(!isset($_SESSION['UserId']))
	{
		header('Location: login.php');
   		die();
	}

	error_reporting(E_ALL); #TODO
	ini_set('error_reporting', E_ALL); #TODO
	
	require_once '../Functions/QueryController.php';
	require_once '../Functions/generateQueryQuestions.php';
	
	require_once '../Services/Answer.php';
	require_once '../Services/Physical_Symptom.php';
	require_once '../Services/Neuropsychological_Symptom.php';
	require_once '../Services/Psychological_Test.php';
	require_once '../Services/Medical_Test.php';
	require_once '../Services/Medication.php';
	require_once '../Services/ICD_Codes.php';
	
	$physicalSymptoms = retrievePhysicalSymptomQuestions(); # ../Services/Physical_Symptom
	
	$neuroPsychSymptoms = retrieveNeuropsychologicalSymptomQuestions(); # ../Services/Neuropsychological_Symptom
	
	$psychTestResults = retrievePsychologicalTestQuestions(); # ../Services/Psychological_Test
		
	$diagnosticTestResults = retrieveMedicalTestQuestions(); # ../Services/Medical_Test

	$icdInformation = retrieveAllICDCodes(); # ../Services/ICD_Codes
	
	$prescriptionInformation = retrieveMedicationList(); # ../Services/Medication
	
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Query</title>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js" type="text/javascript"></script>
<script src="../JavaScript/jQueryTabs/js/jquery-1.6.2.min.js" type="text/javascript"></script>
<script src="../JavaScript/jQueryTabs/js/jquery-ui-1.8.16.custom.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>

<link rel="stylesheet" type="text/css" href="../JavaScript/jQueryTabs/css/custom-theme/jquery-ui-1.8.16.custom.css"/>
<link rel="stylesheet" type="text/css" href="../Styler.css"/>


<script type="text/javascript">

function loadScript(url, callback)
{
    // adding the script tag to the head as suggested before
   head = document.getElementsByTagName('head')[0];
   script = document.createElement('script');
   script.type = 'text/javascript';
   script.src = '../Javascript/' + url;

  script.onerror = function() {errorLoading('Could not load ' + url + '. Some functionality might not work!');};

   // then bind the event to the callback function 
   // there are several events for cross browser compatibility
   script.onload = callback(url);
   
   // fire the loading
   head.appendChild(script);
}

function loadScriptResponse(url) {
	console.log('loaded ' + url);
}

function errorLoading(error) {
	alert(error);
	return true;
}

$(document).ready(function(){
	
	$("#queryBlock").tabs();

	loadScript('underscore.js', loadScriptResponse);
	loadScript('backbone.js', loadScriptResponse);
	loadScript('models.js', loadScriptResponse);
	loadScript('js_basic_functions.js', loadScriptResponse);
	loadScript('library.js', loadScriptResponse);
	loadScript('query.js', loadScriptResponse);
	loadScript('views.js', loadScriptResponse);
	
	
	$("#startDateDosage").datepicker({ minDate: new Date(1950, 01, 01), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#endDateDosage").datepicker({maxDate: new Date(9999, 01, 01), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#DD1").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#DD2").datepicker({maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#DOB1").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#DOB2").datepicker({maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#physicalSymptomDateBegin").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#physicalSymptomDateEnd").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#neuroPsychSymptomDateBegin").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#neuroPsychSymptomDateEnd").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#psychTestDateBegin").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#psychTestDateEnd").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#diagnosticTestDateBegin").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#diagnosticTestDateEnd").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#icdDateBegin").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	$("#icdDateEnd").datepicker({ minDate: new Date(1950, 01, 01), maxDate: new Date(), showOn: 'both', dateFormat: "yy-mm-dd"});
	

	var dosages = new Array();
	for (var i = 5; i <= 2000; i = i + 5) {
		dosages.push(i.toString());
	}
	$("#queryDosageID").autocomplete({
		source: dosages
	});
});

</script>

</head>

<body>
<div id="header"></div>

<div id="mainMenu" style="height: 116px; width: 100px;">
    	<ul style="list-style: none outside none;">
	        <li>
	       	 	<a href="home.php">Home</a>
	        </li> 
	         
	        <li style="border-bottom: 1px solid #FD9D45;">
	       	 	<a href="logout.php">Logout</a>
	        </li>
	        
	        <li>
	        	<a href="queryInformation.php">Help</a>
	        </li>
	        
        </ul>
</div>


<div id="createQueryForm"> <!-- method="post" name="queryForm"> -->

	<div id="queryTotal">
	
	<div id="queryTitle">
		Query Creation
	</div>
	
		<?php if (isset($ValidationErrors)) { ?>
		
			<div class="noQueryResults" style="left: 0px; top: 110px;">
				<img src="../Images/error.png" style="float:left; margin: 5px 5px 5px 15px;"></img>
				<p style="font-weight: bold; line-height: 1; margin: 5px 5px 5px 55px;">No Results</p>
				<p style="line-height: 1; margin: 5px 5px 5px 55px;">Please Try a Different Combination of Options</p>
			</div>
			
		<?php } ?>
	
	
	<div id="queryBlock">
    	
    	<ul>
    		<li><a href="#basicpatientInfoQuery">Basic Information</a></li>
			<li><a href="#physicalSymptoms">Physical Symptoms</a></li>
			<li><a href="#neuroPsySymptoms">Neuropsychological Symptoms</a></li>
			<li><a href="#psychologicalTestInfo">Psychological Test Results</a></li>
			<li><a href="#diagnosticInformation">Diagnostic Test</a></li>
			<li><a href="#icdInformation">ICD9 Information</a></li>
			<li><a href="#prescriptionInformation">Prescriptions</a></li>
		</ul>
    	
		<form id="basicpatientInfoQuery" method="post">
    		
    		 <table class="tableClass" border="1">
			                
			                <tr>
			                	<th>Date Diagnosed Between</th>
			                	<td>
			                		<input type="text" id="DD1" name="DD1" value="<?php if (isset($_POST['DD1'])) echo $_POST['DD1']; else echo "Leave blank for no value";?>"/>
			                		<input type="text" id="DD2" name="DD2" value="<?php if (isset($_POST['DD2'])) echo $_POST['DD2']; else echo "Leave blank for no value";?>"/>
			                	</td>
			                </tr>
			                
			                <tr>
			                	<th>Date of Birth Between</th>
			                	<td>
			                		<input type="text" id="DOB1" name="DOB1" value="<?php if (isset($_POST['DOB1'])) echo $_POST['DOB1']; else echo "Leave blank for no value";?>"/>
			                		<input type="text" id="DOB2" name="DOB2" value="<?php if (isset($_POST['DOB2'])) echo $_POST['DOB2']; else echo "Leave blank for no value";?>"/>
			                	</td>
			                </tr>
			                
			                <tr>
			                	<th>Gender</th>
			                	<td><select id="selectGender" name="selectGender">
			                			<option value="E" <?php if (isset($_POST['selectGender']) && $_POST['selectGender'] == "E") echo 'selected="selected"';?> >Either</option>
				                		<option value="M"<?php if (isset($_POST['selectGender']) && $_POST['selectGender'] == "M") echo 'selected="selected"';?> >M</option>
				                		<option value="F"<?php if (isset($_POST['selectGender']) && $_POST['selectGender'] == "F") echo 'selected="selected"';?> >F</option>
									</select>
								</td>
			                </tr>
			                
			                <tr>
			                	<th>Relationship Status</th>
			                	<td><select id="selectRelationship" name="selectRelationship">
				                		<option value="E"<?php if (isset($_POST['selectRelationship']) && $_POST['selectRelationship'] == "E") echo 'selected="selected"';?> >Either</option>
				                		<option value="0"<?php if (isset($_POST['selectRelationship']) && $_POST['selectRelationship'] == "0") echo 'selected="selected"';?> >Single</option>
				                		<option value="1"<?php if (isset($_POST['selectRelationship']) && $_POST['selectRelationship'] == "1") echo 'selected="selected"';?> >In a Relationship</option>
									</select>
								</td>
			                </tr>
			                
			                <tr>
			                	<th>Occupation Status</th>
			                	<td><select id="selectOccupation" name="selectOccupation">
				                		<option value="E"<?php if (isset($_POST['selectOccupation']) && $_POST['selectOccupation'] == "E") echo 'selected="selected"';?> >Either</option>
				                		<option value="0"<?php if (isset($_POST['selectOccupation']) && $_POST['selectOccupation'] == "0") echo 'selected="selected"';?> >Unemployed</option>
				                		<option value="1"<?php if (isset($_POST['selectOccupation']) && $_POST['selectOccupation'] == "1") echo 'selected="selected"';?> >Employed</option>
									</select>
								</td>
			                </tr>
               				                				      			
			                <tr id="ticksInWorkEnv">
			                	<th>Ticks in Work Environment</th>
			                	<td><select id="selectTickWorkEnv" name="selectTickWorkEnv">
				                		<option value="E"<?php if (isset($_POST['selectTickWorkEnv']) && $_POST['selectTickWorkEnv'] == "E") echo 'selected="selected"';?> >Either</option>
				                		<option value="0"<?php if (isset($_POST['selectTickWorkEnv']) && $_POST['selectTickWorkEnv'] == "0") echo 'selected="selected"';?> >No</option>
				                		<option value="1"<?php if (isset($_POST['selectTickWorkEnv']) && $_POST['selectTickWorkEnv'] == "1") echo 'selected="selected"';?> >Yes</option>
									</select>
								</td>
			                </tr>
			    
							<tr>
			                	<th>Ticks in Hunting Environment</th>
			                	<td><select id="selectTickHuntEnv" name="selectTickHuntEnv">
				                		<option value="E"<?php if (isset($_POST['selectTickHuntEnv']) && $_POST['selectTickHuntEnv'] == "E") echo 'selected="selected"';?> >Either</option>
				                		<option value="0"<?php if (isset($_POST['selectTickHuntEnv']) && $_POST['selectTickHuntEnv'] == "0") echo 'selected="selected"';?> >No</option>
				                		<option value="1"<?php if (isset($_POST['selectTickHuntEnv']) && $_POST['selectTickHuntEnv'] == "1") echo 'selected="selected"';?> >Yes</option>
									</select>
								</td>
			                </tr>
			                
			                 <tr>
			                	<th>Ticks in Play Environment</th>
			                	<td><select id="selectTickPlayEnv" name="selectTickPlayEnv">
				                		<option value="E"<?php if (isset($_POST['selectTickPlayEnv']) && $_POST['selectTickPlayEnv'] == "E") echo 'selected="selected"';?> >Either</option>
				                		<option value="0"<?php if (isset($_POST['selectTickPlayEnv']) && $_POST['selectTickPlayEnv'] == "0") echo 'selected="selected"';?> >No</option>
				                		<option value="1"<?php if (isset($_POST['selectTickPlayEnv']) && $_POST['selectTickPlayEnv'] == "1") echo 'selected="selected"';?> >Yes</option>
									</select>
								</td>
			                </tr>
			                
			                <tr>
			                	<th>Ticks in Garden Environment</th>
			                	<td><select id="selectTickGardenEnv" name="selectTickGardenEnv">
				                		<option value="E"<?php if (isset($_POST['selectTickGardenEnv']) && $_POST['selectTickGardenEnv'] == "E") echo 'selected="selected"';?> >Either</option>
				                		<option value="0"<?php if (isset($_POST['selectTickGardenEnv']) && $_POST['selectTickGardenEnv'] == "0") echo 'selected="selected"';?> >No</option>
				                		<option value="1"<?php if (isset($_POST['selectTickGardenEnv']) && $_POST['selectTickGardenEnv'] == "1") echo 'selected="selected"';?> >Yes</option>
									</select>
								</td>
			                </tr>
			                <tr>
			                	<th>Tickbite Caused Original Disease</th>
			                	<td><select id="selectTickBite" name="selectTickBite">
				                		<option value="E"<?php if (isset($_POST['selectTickBite']) && $_POST['selectTickBite'] == "E") echo 'selected="selected"';?> >Either</option>
				                		<option value="0"<?php if (isset($_POST['selectTickBite']) && $_POST['selectTickBite'] == "0") echo 'selected="selected"';?> >No</option>
				                		<option value="1"<?php if (isset($_POST['selectTickBite']) && $_POST['selectTickBite'] == "1") echo 'selected="selected"';?> >Yes</option>
									</select>
								</td>
			                </tr>
			                <tr>
			                	<th>Currently Has a Rash</th>
			                	<td><select id="selectRash" name="selectRash">
				                		<option value="E"<?php if (isset($_POST['selectRash']) && $_POST['selectRash'] == "E") echo 'selected="selected"';?> >Either</option>
				                		<option value="0"<?php if (isset($_POST['selectRash']) && $_POST['selectRash'] == "0") echo 'selected="selected"';?> >No</option>
				                		<option value="1"<?php if (isset($_POST['selectRash']) && $_POST['selectRash'] == "1") echo 'selected="selected"';?> >Yes</option>
									</select>
								</td>
			                </tr>
						</table>

    	</form>
 	
    	
		<form id="physicalSymptoms" method="post">
	    		
    		<!--<ul style="padding-left: 20px;">
				<li class="divider" id="collapsePhys">Physical Symptoms</li>
    		</ul>-->
    			
    		<div id="physicalQueryBlock">	    		
	    		<?php 
	    		$numColumns = 3;
	    		$limit = count($physicalSymptoms);
	    		$limitColumn1 = ceil($limit/$numColumns);
	    		$limitColumn2 = $limitColumn1 * 2;
	    			?>
	    				
	    		<ul class="queryBlockColumn">	
		    		<?php for ($i = 0; $i < $limitColumn1; $i++) {?>
		    			<li>
			    			<div class="answerLi1" id="physColumnColl<?php echo $physicalSymptoms[$i]['qnumber'];?>">
			    				<?php echo $physicalSymptoms[$i]['text']?>
			    			</div>
		    			</li>
		    			
		    			<li id="physAnswers<?php echo $physicalSymptoms[$i]['qnumber'];?>">
		    				<?php print_r(generateQuestions ($physicalSymptoms[$i], "physical_symptom_questions")); ?>	    			
		    			</li>
		    		<?php } ?>
	    		</ul>

	    		<ul class="queryBlockColumn">
	    			<?php for ($i = $limitColumn1; $i < $limitColumn2; $i++) {?>
		    			<li>
			    			<div class="answerLi1" id="physColumnColl<?php echo $physicalSymptoms[$i]['qnumber'];?>">
			    				<?php echo $physicalSymptoms[$i]['text']?>
			    			</div>
		    			</li>
		    			
		    			<li id="physAnswers<?php echo $physicalSymptoms[$i]['qnumber'];?>">
		    				<?php print_r(generateQuestions ($physicalSymptoms[$i], "physical_symptom_questions")); ?>	    			
		    			</li>
		    		
		    		<?php } ?>
	    		</ul>
	    		
	    		<ul class="queryBlockColumn">
		    		<?php for ($i = $limitColumn2; $i < $limit; $i++) {?>
			    			<li>
				    			<div class="answerLi1" id="physColumnColl<?php echo $physicalSymptoms[$i]['qnumber'];?>">
				    				<?php echo $physicalSymptoms[$i]['text']?>
				    			</div>
			    			</li>
			    			
			    			<li id="physAnswers<?php echo $physicalSymptoms[$i]['qnumber'];?>">
			    				<?php print_r(generateQuestions ($physicalSymptoms[$i], "physical_symptom_questions")); ?>	    			
			    			</li>
			    		
		    		<?php } ?>
	    		</ul>
	    		
	    		<ul class="queryBlockColumn">		    			
	    				<li>
		    				<div style="margin-left: auto; margin-right: auto; width: 100px;">Begin Date</div>
		    				<div style="margin-bottom: 40px;  height: 30%; width: 80%; margin-left: auto; margin-right: auto; margin-top: 10px;">
		    					<input type="text" id="physicalSymptomDateBegin"></input>
		    				</div>
	    				</li>
	    				
	    				<li>
		    				<div style="margin-left: auto; margin-right: auto; width: 100px;">End Date</div>	
		    				<div style="height: 30%; width: 80%; margin-left: auto; margin-right: auto;">
		    					<input type="text" id="physicalSymptomDateEnd"></input>
		    				</div>
	    				</li>
	    		</ul>
		    		
    		</div>
    		
    	</form>
	
	
		<form id="neuroPsySymptoms" method="post">
					
				<!--<ul style="padding-left: 20px;">
					<li class="divider" id="collapseNeuro">NeuroPsychological Symptoms</li>
	    		</ul>-->
	    			
	    		<div id="neurQueryBlock">	    		
		    		<?php 
		    		$numColumns = 3;
		    		$limit = count($neuroPsychSymptoms);
		    		$limitColumn1 = ceil($limit/$numColumns);
		    		$limitColumn2 = $limitColumn1 * 2;
		    			?>
		    				
		    		<ul class="queryBlockColumn">	
			    		<?php for ($i = 0; $i < $limitColumn1; $i++) {?>
			    			<li>
				    			<div class="answerLi1" id="physColumnColl<?php echo $neuroPsychSymptoms[$i]['qnumber'];?>">
				    				<?php echo $neuroPsychSymptoms[$i]['text']?>
				    			</div>
			    			</li>
			    			
			    			<li id="physAnswers<?php echo $neuroPsychSymptoms[$i]['qnumber'];?>">
			    				<?php print_r(generateQuestions ($neuroPsychSymptoms[$i], "physical_symptom_questions")); ?>	    			
			    			</li>
			    		<?php } ?>
		    		</ul>
	
		    		<ul class="queryBlockColumn">
		    			<?php for ($i = $limitColumn1; $i < $limitColumn2; $i++) {?>
			    			<li>
				    			<div class="answerLi1" id="physColumnColl<?php echo $neuroPsychSymptoms[$i]['qnumber'];?>">
				    				<?php echo $neuroPsychSymptoms[$i]['text']?>
				    			</div>
			    			</li>
			    			
			    			<li id="physAnswers<?php echo $neuroPsychSymptoms[$i]['qnumber'];?>">
			    				<?php print_r(generateQuestions ($neuroPsychSymptoms[$i], "physical_symptom_questions")); ?>	    			
			    			</li>
			    		
			    		<?php } ?>
		    		</ul>
		    		
		    		<ul class="queryBlockColumn">
			    		<?php for ($i = $limitColumn2; $i < $limit; $i++) {?>
				    			<li>
					    			<div class="answerLi1" id="physColumnColl<?php echo $neuroPsychSymptoms[$i]['qnumber'];?>">
					    				<?php echo $neuroPsychSymptoms[$i]['text']?>
					    			</div>
				    			</li>
				    			
				    			<li id="physAnswers<?php echo $neuroPsychSymptoms[$i]['qnumber'];?>">
				    				<?php print_r(generateQuestions ($neuroPsychSymptoms[$i], "physical_symptom_questions")); ?>	    			
				    			</li>
				    		
			    		<?php } ?>
		    		</ul>
		    		
		    		<ul class="queryBlockColumn">
		    			<li>
		    				<div style="margin-left: auto; margin-right: auto; width: 100px;">Begin Date</div>
		    				<div style="margin-bottom: 40px; height: 30%; width: 80%; margin-left: auto; margin-right: auto; margin-top: 10px;">
		    					<input type="text" id="neuroPsychSymptomDateBegin"></input>
		    				</div>
		    			</li>
		    			<li>
		    				<div style="margin-left: auto; margin-right: auto; width: 100px;">End Date</div>	
		    				<div style="height: 30%; width: 80%; margin-left: auto; margin-right: auto;">
		    					<input type="text" id="neuroPsychSymptomDateEnd"></input>
		    				</div>
		    			</li>
		    		</ul>
			    		
	    		</div>				
			</form>	
	
		
		<form id="psychologicalTestInfo" method="post" style="padding-bottom: 20px;">
					
				<?php #print_r($psychTestResults); die();?>	
					
					
				<?php 
		    		$numColumns = 3;
		    		$limit = count($psychTestResults);
		    		$limitColumn1 = ceil($limit/$numColumns);
		    		$limitColumn2 = $limitColumn1 * 2;
		    			?>	

	    			
		  		<div id="psychTestQueryBlock">
		  		
			  		<ul class="queryBlockColumn">
			  			<?php for ($i = 0; $i < $limitColumn1; $i++) {?>
  					    	<li>
  						  		<div class="answerLi1" id="psychColumnColl<?php echo $psychTestResults[$i]['qnumber'];?>">
  						   			<?php echo $psychTestResults[$i]['text']?>
  						  		</div>
  					    	</li>
  					    			
  					  		<li id="physAnswers<?php echo $psychTestResults[$i]['qnumber'];?>">
  					   			<?php print_r(generateQuestions ($psychTestResults[$i], "psychological_test_questions")); ?>	    			
  					    	</li>
  					    <?php } ?>
  				    </ul>
		  		
		  					    		<ul class="queryBlockColumn">
		    			<?php for ($i = $limitColumn1; $i < $limitColumn2; $i++) {?>
			    			<li>
				    			<div class="answerLi1" id="psychColumnColl<?php echo $psychTestResults[$i]['qnumber'];?>">
				    				<?php echo $psychTestResults[$i]['text']?>
				    			</div>
			    			</li>
			    			
			    			<li id="physAnswers<?php echo $psychTestResults[$i]['qnumber'];?>">
			    				<?php print_r(generateQuestions ($psychTestResults[$i], "psychological_test_questions")); ?>	    			
			    			</li>
			    		
			    		<?php } ?>
		    		</ul>
		    		
		    		<ul class="queryBlockColumn">
			    		<?php for ($i = $limitColumn2; $i < $limit; $i++) {?>
				    			<li>
					    			<div class="answerLi1" id="psychColumnColl<?php echo $psychTestResults[$i]['qnumber'];?>">
					    				<?php echo $psychTestResults[$i]['text']?>
					    			</div>
				    			</li>
				    			
				    			<li id="physAnswers<?php echo $psychTestResults[$i]['qnumber'];?>">
				    				<?php print_r(generateQuestions ($psychTestResults[$i], "psychological_test_questions")); ?>	    			
				    			</li>
				    		
			    		<?php } ?>
		    		</ul>
		    		
		    		<ul class="queryBlockColumn">
		    			<li>
		    				<div style="margin-left: auto; margin-right: auto; width: 100px;">Begin Date</div>
		    				<div style="margin-bottom: 40px; height: 30%; width: 80%; margin-left: auto; margin-right: auto; margin-top: 10px;">
		    					<input type="text" id="psychTestDateBegin"></input>
		    				</div>
		    			</li>
		    			<li>
		    				<div style="margin-left: auto; margin-right: auto; width: 100px;">End Date</div>	
		    				<div style="height: 30%; width: 80%; margin-left: auto; margin-right: auto;">
		    					<input type="text" id="psychTestDateEnd"></input>
		    				</div>
		    			</li>
		    		</ul>
	    		
	    		
	    		</div>
	    		
	    	</form>
    	
    	
    	<form id="diagnosticInformation" method="post">
    			
    			<!--<div>
	    			<ul style="padding-left: 20px;">
			    		<li class="divider" id="diagTestCollapse">Diagnostic Test Information</li>
		    		</ul>
	    		</div>-->
	    	
	    	<?php# print_r($diagnosticTestResults); ?>
	    		
	    	<div id="diagTestQueryBlock">
	    		
	    		<?php 
		    		$numColumns = 3;
		    		$limit = count($diagnosticTestResults);
		    		$limitColumn1 = ceil($limit/$numColumns);
		    		$limitColumn2 = $limitColumn1 * 2;
		    			?>	
	    		<!--<ul style="padding-left: 20px;">
				<li class="divider" id="collapsePsychoTest">Psychological Test Results</li>
	    		</ul>-->
	    			
		  		
			  		<ul class="queryBlockColumn">
			  			<?php for ($i = 0; $i < $limitColumn1; $i++) {?>
  					    	<li>
  						  		<div class="answerLi1" id="diagnosticColumnColl<?php echo $diagnosticTestResults[$i]['qnumber'];?>">
  						   			<?php echo $diagnosticTestResults[$i]['text']?>
  						  		</div>
  					    	</li>
  					    			
  					  		<li id="physAnswers<?php echo $diagnosticTestResults[$i]['qnumber'];?>">
  					   			<?php print_r(generateQuestions ($diagnosticTestResults[$i], "diagnostic_test_questions")); ?>	    			
  					    	</li>
  					    <?php } ?>
  				    </ul>
		  		
		  					    		<ul class="queryBlockColumn">
		    			<?php for ($i = $limitColumn1; $i < $limitColumn2; $i++) {?>
			    			<li>
				    			<div class="answerLi1" id="diagnosticColumnColl<?php echo $diagnosticTestResults[$i]['qnumber'];?>">
				    				<?php echo $diagnosticTestResults[$i]['text']?>
				    			</div>
			    			</li>
			    			
			    			<li id="physAnswers<?php echo $diagnosticTestResults[$i]['qnumber'];?>">
			    				<?php print_r(generateQuestions ($diagnosticTestResults[$i], "diagnostic_test_questions")); ?>	    			
			    			</li>
			    		
			    		<?php } ?>
		    		</ul>
		    		
		    		<ul class="queryBlockColumn">
			    		<?php for ($i = $limitColumn2; $i < $limit; $i++) {?>
				    			<li>
					    			<div class="answerLi1" id="diagnosticColumnColl<?php echo $diagnosticTestResults[$i]['qnumber'];?>">
					    				<?php echo $diagnosticTestResults[$i]['text']?>
					    			</div>
				    			</li>
				    			
				    			<li id="physAnswers<?php echo $diagnosticTestResults[$i]['qnumber'];?>">
				    				<?php print_r(generateQuestions ($diagnosticTestResults[$i], "diagnostic_test_questions")); ?>	    			
				    			</li>
				    		
			    		<?php } ?>
		    		</ul>
		    		
		    		<ul class="queryBlockColumn">
		    			<li>
		    				<div style="margin-left: auto; margin-right: auto; width: 100px;">Begin Date</div>
		    				<div style="margin-bottom: 40px; height: 30%; width: 80%; margin-left: auto; margin-right: auto; margin-top: 10px;">
		    					<input type="text" id="diagnosticTestDateBegin"></input>
		    				</div>
		    			</li>
		    			<li>
		    				<div style="margin-left: auto; margin-right: auto; width: 100px;">End Date</div>	
		    				<div style="height: 30%; width: 80%; margin-left: auto; margin-right: auto;">
		    					<input type="text" id="diagnosticTestDateEnd"></input>
		    				</div>
		    			</li>
		    		</ul>
	    		
	    	</div>
    		
    	</form>
    	
    	<form id="icdInformation" method="post">
    		<?php# print_r($icdInformation);?>
    		<ul class="queryBlockColumn">
    			<li class="prescriptionNameQuery">
		    		ICD Code
		    	</li>
		    	<li>
	    			<select name="icdChoose" style="width: 200px; margin-top: 10px;">
	    				<option value="9999">Choose</option>
		    			<?php 
		    			foreach ($icdInformation as $index => $info) { ?>
		    				<option value="<?php echo $info['id'];?>"><?php echo $info['code'] . " : " . $info['name'];?></option>
		    			<?php } ?>
	    			</select>
    			</li>
		    	
    		</ul>
    		<ul class="queryBlockColumn">
    			<li>
    				<div>
	    				<div style="margin-left: auto; margin-right: auto; width: 100px;">Begin Date</div>
	    				<div style="margin-bottom: 40px; height: 30%; width: 80%; margin-left: auto; margin-right: auto; margin-top: 10px;">
	    					<input type="text" id="icdDateBegin"></input>
	    				</div>
    				</div>
    			</li>
    		</ul>
    		<ul class="queryBlockColumn">
    			<li>
	    			<div>
	    				<div style="margin-left: auto; margin-right: auto; width: 100px;">End Date</div>	
	    				<div style="margin-bottom: 40px; height: 30%; width: 80%; margin-left: auto; margin-right: auto; margin-top: 10px;">
	    					<input type="text" id="icdDateEnd"></input>
	    				</div>
	    			</div>
    			</li>
    		</ul>
    	
    	</form>
    	
    	
    	<form id="prescriptionInformation" method="post">
    	<?php 
    	
    	$info = $prescriptionInformation;?>	
    		
    		
	    		<ul class="queryBlockColumn" style="width: 190px;">
	    		   		
		    		<li class="prescriptionNameQuery">
		    			Name
		    		</li>
		    		
		    		<li>
		    			<select name="queryPrescriptionChoose">
		    				<option value="-1">Choose</option>
			    			<?php 
			    			foreach ($prescriptionInformation as $row) { ?>
			    				<option value="<?php echo $row['ID'];?>"><?php echo $row['Name'];?></option>
			    			<?php } ?>
		    			</select>
	    			</li>
	    			
	    		</ul>
	    		 
	    		<ul class="queryBlockColumn" style="width: 190px;">
		    		<li>Choose Dosage (mg)</li>	
		    		<li><input type="text" id="queryDosageID" name="queryDosage"/></li>    		
	    		</ul>
	    		
	    		<ul class="queryBlockColumn" style="width: 190px;">
		    		<li>Start Date</li>
		    		<li><input type="text" id="startDateDosage" name="dosageStartDate"/></li>
	    		</ul>
    		
    			<ul class="queryBlockColumn" style="width: 190px;">
    				<li>End Date</li>
		    		<li><input type="text" id="endDateDosage" name="dosageEndDate"/></li>
    			</ul>
    			<ul class="queryBlockColumn" style="width: 190px;">
    				<input type="button" value="Generate Query" class="loginButton" onclick="" />
    			</ul>
    		
    	
    	
    	</form>
    	
	</div>
	
	</div>
	<div id="submitQueryButtonDiv">
		<input type="button" value="Generate Query" class="loginButton" onclick="generateQuery(document.getElementById('basicpatientInfoQuery'), document.getElementById('physicalSymptoms'), document.getElementById('neuroPsySymptoms'), document.getElementById('psychologicalTestInfo'), document.getElementById('diagnosticInformation'), document.getElementById('icdInformation'), document.getElementById('prescriptionInformation'))" />
	</div>
	
</div>

</body>
</html>